﻿using System;
using System.Linq;
using MM.Data.Entity;
using MM.Services.decl;

namespace MM.Services.impl
{
    public class BalanceService : BaseService, IBalanceInterface
    {
        public Balance GetBalanceByDateTime(DateTime dateTime)
        {
            return MyMoneyContext.Balance.FirstOrDefault(_ => _.DateTime == dateTime);
        }

        public void AddBalance(Balance balance)
        {
            if (balance != null) MyMoneyContext.Balance.Add(balance);
            Commit();
        }
    }
}